package com.mia.craftstudio.minecraft;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.minecraft.util.EnumFacing;

public class DirectionHelper {
   public static final EnumFacing[] allDirections;
   public static final EnumFacing[] flatDirections;
   public static final Set directions;
   private static final Map s2triptype;

   public static ImmutableDirectionHolder getDirection(String s) {
      ImmutableDirectionHolder retval = (ImmutableDirectionHolder)s2triptype.get(s.toLowerCase());
      if (retval == null) {
         throw new RuntimeException(String.format("Invalid direction request : %s", s));
      } else {
         return retval;
      }
   }

   public static Set getAllDirections() {
      return directions;
   }

   static {
      allDirections = new EnumFacing[]{EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.UP, EnumFacing.DOWN};
      flatDirections = new EnumFacing[]{EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.EAST};
      s2triptype = new HashMap();
      EnumFacing[] var0 = allDirections;
      int var1 = var0.length;

      for(int var2 = 0; var2 < var1; ++var2) {
         EnumFacing fd1 = var0[var2];
         String fd1Letter = fd1.toString().substring(0, 1);
         s2triptype.put(fd1Letter, new ImmutableDirectionHolder(new EnumFacing[]{fd1}));
         EnumFacing[] var5 = allDirections;
         int var6 = var5.length;

         for(int var7 = 0; var7 < var6; ++var7) {
            EnumFacing fd2 = var5[var7];
            if (PortUtils.getOpposite(fd1) != fd2) {
               String fd2Letter = fd2.toString().substring(0, 1);
               s2triptype.put(fd1Letter + fd2Letter, new ImmutableDirectionHolder(new EnumFacing[]{fd1, fd2}));
               EnumFacing[] var10 = allDirections;
               int var11 = var10.length;

               for(int var12 = 0; var12 < var11; ++var12) {
                  EnumFacing fd3 = var10[var12];
                  if (PortUtils.getOpposite(fd1) != fd3 && PortUtils.getOpposite(fd2) != fd3) {
                     String fd3Letter = fd3.toString().substring(0, 1);
                     s2triptype.put(fd1Letter + fd2Letter + fd3Letter, new ImmutableDirectionHolder(new EnumFacing[]{fd1, fd2, fd3}));
                  }
               }
            }
         }
      }

      directions = new HashSet(s2triptype.values());
   }
}
